package com.org.dao.impl;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

import com.org.IbatisBaseDao;
import com.org.controller.LogController;
import com.org.dao.IMemberDao;
import com.org.model.Member;


@Repository
@SuppressWarnings("all")
public class MemberDaoImpl extends IbatisBaseDao implements IMemberDao{
	private Logger logger=Logger.getLogger(MemberDaoImpl.class);
	
	public Member getMemberByUsername(String username) {
		Member obj;
		try {
			Map map=new HashMap();
			map.put("username", username);
			obj = (Member) sqlMapClient.queryForObject("findMemberByUserName",map );
			return obj;
		} catch (SQLException e) {
			logger.info("getMemberByUsername"+e.getMessage());
			e.printStackTrace();
		}
		//obj=(obj==null)?new Member():obj;
		return null;
	}

	@Override
	public boolean getVerifyMember(String username, String password) {
		Map map=new HashMap();
		map.put("username", username);
		map.put("password", password);
		try {
			List lists=sqlMapClient.queryForList("findVerifyMember", map);
			if(lists!=null&&lists.size()>0){
				return true;
			}else{
				return false;
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return false;
	}

	@Override
	public Integer update(Member loginMember) {
		try {
			Integer result= sqlMapClient.update("updateMember", loginMember);
			return result;
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return 0;
	}
	
}
